package com.example.llollama.commponent;

import org.springframework.ai.document.Document;
import org.springframework.ai.reader.tika.TikaDocumentReader;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description: TODO
 * @author: lonely
 * @date: 2024年11月19日 22:51
 */
@Component
public class MyTikaDocumentReader {
    private final Resource resource;


        MyTikaDocumentReader(@Value("classpath:/闫磊.docx")
                         Resource resource) {
        this.resource = resource;
    }

    public List<Document> loadText() {
        TikaDocumentReader tikaDocumentReader = new TikaDocumentReader(resource);
        return tikaDocumentReader.read();
    }
}
